/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import model.Puzzle8Model;
import model.Puzzle8RobotModel;
import model.Puzzle8SolverModel;
import util.NoMoreMovesException;

/**
 *
 * @author comercio
 */
public class DefaultController extends AbstractController {
    private Puzzle8Model puzzleModel;
    private Puzzle8RobotModel robotModel;
    private Puzzle8SolverModel robotSolver;
    
    public void addPuzzleModel(Puzzle8Model model) {
        puzzleModel = model;
        model.addPropertyChangeListener(this);
    }
    public void addRobotModel(Puzzle8RobotModel model) {
        robotModel = model;
        model.addPropertyChangeListener(this);
    }
    public void moveNext() throws NoMoreMovesException{
        robotModel.nextMove();
    }
    public Integer[] getPuzzlePositions(){
        return puzzleModel.getPositions();
    }
    public String getPuzzleString(){
        return puzzleModel.toString();
    }
    public void movePuzzleRandomly(int numberOfMoves){
        robotModel.moveRandomly(numberOfMoves);
    }
    public void calculateSolution(){
        robotModel.calculateSolution();
    }
    public void autoPlay() throws NoMoreMovesException{
        robotModel.autoPlay();
    }

    public void addPuzzleSolver(Puzzle8SolverModel solver) {
        robotSolver = solver;
        solver.addPropertyChangeListener(this);
    }
    
}
